﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using ByteSite.Common;
using System.Linq.Expressions;

namespace ByteSite.BLL
{
    /// <summary>
    ///站点管理
    /// </summary>
    public partial class quartz_log
    {
        private readonly DAL.Data data;

        public quartz_log()
        {
            data = new DAL.Data();
        }
        

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int id)
        {
            return data.Exists<Entitys.QuartzLog>(id);
        }

        public bool Exists(Expression<Func<Entitys.QuartzLog, bool>> whereExpression)
        {
            return data.Exists<Entitys.QuartzLog>(whereExpression);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Entitys.QuartzLog model)
        {
            try
            {
                model.id = data.Insert(model);
            }
            catch
            {
                return 0;
            }
            return Utils.ObjToInt(model.id, 0);
        }

        private bool Update(Entitys.QuartzLog model)
        {
            try
            {
                data.Update<Entitys.QuartzLog>(model);
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }

        public bool Delete(int id)
        {
            return data.Delete<Entitys.QuartzLog>(id);
        }

        public int Delete(Expression<Func<Entitys.QuartzLog, bool>> whereExpression)
        {
            return data.Delete<Entitys.QuartzLog>(whereExpression);
        }

        public Entitys.QuartzLog GetModel(int id)
        {
            return data.Get<Entitys.QuartzLog>(id);
        }

        public Entitys.QuartzLog GetModel(Expression<Func<Entitys.QuartzLog, bool>> whereExpression)
        {
            return data.Get<Entitys.QuartzLog>(whereExpression);
        }

        public List<Entitys.QuartzLog> GetList(int top, Expression<Func<Entitys.QuartzLog, bool>> whereExpression, Expression<Func<Entitys.QuartzLog, object>> orderExpression)
        {
            return data.List<Entitys.QuartzLog>(top, whereExpression, orderExpression);
        }

        public List<Entitys.QuartzLog> GetList(Expression<Func<Entitys.QuartzLog, bool>> whereExpression, Expression<Func<Entitys.QuartzLog, object>> orderExpression)
        {
            return data.List<Entitys.QuartzLog>(whereExpression, orderExpression);
        }

        public List<Entitys.QuartzLog> GetList(int pageSize, int pageIndex, Expression<Func<Entitys.QuartzLog, bool>> whereExpression, Expression<Func<Entitys.QuartzLog, object>> orderExpression, out int recordCount)
        {
            return data.List<Entitys.QuartzLog>(pageSize, pageIndex, whereExpression, orderExpression, out recordCount);
        }



    }
}